Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spark Jupyter getting started docker compose #295

Merged
merged 16 commits into from
Oct 15, 2024

Conversation

kevinjqliu
Copy link
Contributor

@kevinjqliu kevinjqliu commented Sep 15, 2024

Description

This PR moves the docker-compose-jupyter.yml file (and the notebooks/ directory), formerly in the top-level directory, into the getting-started/spark/ folder.

The purpose is to unify the "getting started" guides into the same directory.

Fixes #110

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • Documentation update
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

docker-compose -f getting-started/spark/docker-compose.yml up

Open the SparkPolaris.ipynb Jupyter notebook
Grab the root principal credentials from the Polaris service and replace in the notebook cell.
Run all cells in notebook

Checklist:

Please delete options that are not relevant.

  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • If adding new functionality, I have discussed my implementation with the community using the linked GitHub issue

@kevinjqliu
Copy link
Contributor Author

I want to make sure this is something we want to do before proceeding to add more to the PR

cc @collado-mike / @flyrain

@flyrain
Copy link
Contributor

flyrain commented Sep 16, 2024

Make sense to me. Thanks @kevinjqliu! Do we have any doc for its usage? We may add doc if not.

@kevinjqliu
Copy link
Contributor Author

@flyrain yep i'll have a README in here, similar to the trino one

@flyrain
Copy link
Contributor

flyrain commented Sep 16, 2024

Sounds good. We will need these doc to be in the Polaris doc site, like this https://polaris.apache.org/docs/overview/. I couldn't find Trino's doc there, this may involve doc publish and link. cc @jbonofre

@kevinjqliu
Copy link
Contributor Author

I see, this is the README for trino. I'll add a similar README for spark.

As a follow-up, we can change the Polaris doc to refer to these guides https://polaris.apache.org/docs/quickstart

@collado-mike
Copy link
Contributor

This looks good to me. We should change the name of the compose file to just docker-compose.yml so we don't have to specify the filename in the command line :)

@kevinjqliu
Copy link
Contributor Author

@collado-mike makes sense, will do.

I have a question on slack about unable to assume the role arn:aws:iam::631484165566:role/datalake-storage-integration-role in the notebook, do you mind taking a look?

@kevinjqliu
Copy link
Contributor Author

r? @flyrain @RussellSpitzer @collado-mike

Also opened #319 to update the Polaris doc site once this is merged.

getting-started/spark/README.md Outdated Show resolved Hide resolved
getting-started/spark/README.md Outdated Show resolved Hide resolved
getting-started/spark/README.md Outdated Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit conflicted about this doc. It feels like it doesn't really teach the reader anything about Polaris, although it does give you a really fast way to get bootstrapped.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes I'll admit, this README is a filler for now as a way to get spark & polaris up and running quickly

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it might be easier to use the CLI here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be, if you want a spark-shell. I think the jupyter notebook does a good job of explaining a lot of the concepts

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I meant the polaris CLI instead of using curl

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah i dont know how to use the polaris CLI, so i just copied directly from https://github.com/apache/polaris/blob/main/regtests/run_spark_sql.sh

@kevinjqliu
Copy link
Contributor Author

md check intermittently shows https://redocly.com/docs/cli/installation as 400 error, weird

@flyrain
Copy link
Contributor

flyrain commented Oct 1, 2024

md check intermittently shows https://redocly.com/docs/cli/installation as 400 error, weird

It's OK to remove the link for now since we’re transitioning to Hugo.

@kevinjqliu
Copy link
Contributor Author

@flyrain just had to run the CI a few times, it's unrelated to this change

@kevinjqliu kevinjqliu force-pushed the kevinjqliu/getting-started-spark branch from b75d998 to 3eda72b Compare October 3, 2024 19:59
@kevinjqliu kevinjqliu force-pushed the kevinjqliu/getting-started-spark branch from 3eda72b to 48a9f00 Compare October 15, 2024 14:58
@@ -41,5 +41,5 @@ jobs:
with:
use-quiet-mode: 'yes'
config-file: '.github/workflows/check-md-link-config.json'
folder-path: 'regtests, regtests/client/python/docs, regtests/client/python, .github, build-logic, polaris-core, polaris-service, extension, spec, k8, notebooks'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR moved notebooks/ from top-level directory into the getting-started/ directory

Copy link
Contributor

@flyrain flyrain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @kevinjqliu for working on it. LGTM overall. Left some comments and questions.

```

This will spin up 3 container services
* The `polaris` service for running Apache Polaris
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: could we be more explicit that it starts with an in-memory metastore?

This will spin up 3 container services
* The `polaris` service for running Apache Polaris
* The `jupyter` service for running Jupyter notebook with PySpark
* The `create-polaris-catalog` service to run setup script and create local catalog in Polaris
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

local catalog -> a catalog backed by the local file system?

SPARK_BEARER_TOKEN="${REGTEST_ROOT_BEARER_TOKEN:-principal:root;realm:default-realm}"
POLARIS_CATALOG_NAME="${POLARIS_CATALOG_NAME:-polaris_demo}"

# create a catalog backed by the local filesystem
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not entirely sure if we need this file. Could we handle everything directly within the notebook, like the other operations in SparkPolaris.ipynb? Would it simplify things if we moved the operations there?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could, but i think its a good idea to separate infra code (this script) from application code (the notebook)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could initialize catalog in notebook as well. I feel it's more flexible that way. for example, you don't have to worry about the an env variable for catalog name. But I'm OK with either one. Not a blocker for me.


# Getting Started with Apache Spark and Apache Polaris

This getting started guide provides a `docker-compose` file to set up [Apache Spark](https://spark.apache.org/) with Apache Polaris. Apache Polaris is configured as an Iceberg REST Catalog in Spark.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is other way to try Spark with Polaris without docker, it's a not a blocker, we can add it later.

@kevinjqliu
Copy link
Contributor Author

Thanks for the review @flyrain, addressed your comments

@flyrain
Copy link
Contributor

flyrain commented Oct 15, 2024

We cannot merge any PR until #374 is merged.

@kevinjqliu
Copy link
Contributor Author

Thanks for the heads up, I'll rebase once that PR's merged

@kevinjqliu kevinjqliu force-pushed the kevinjqliu/getting-started-spark branch from a0f6c9a to 797fabb Compare October 15, 2024 21:17
@kevinjqliu
Copy link
Contributor Author

@flyrain took your advice, moved getting-started/spark/create-polaris-catalog.sh logic into the jupyter notebook.
Also rebased off latest main. I think this PR is good to go. Please take a look!

@flyrain flyrain merged commit ac01e2d into apache:main Oct 15, 2024
5 checks passed
@flyrain
Copy link
Contributor

flyrain commented Oct 15, 2024

Thanks a lot for working on it, @kevinjqliu! Thanks all for the review.

@kevinjqliu kevinjqliu deleted the kevinjqliu/getting-started-spark branch October 15, 2024 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE REQUEST] Quick Start: Spark via docker
4 participants